package com.hspedu.Enum;

/**
 * @version 1.0
 * @author 彪哥
 */
public class Enumeration02 {

}
//演示自定义枚举类实现
class Season {
    private String name;
    private String desc;   //描述

    //使用静态的属性会导致Season类加载 所以添加final 优化，
    public static final Season SPRING = new Season("春天", "温暖");
    public static final Season SUMMER = new Season("夏天", "炎热");
    public static final Season AUTUMN = new Season("秋天", "凉爽");
    public static final Season WINTER = new Season("冬天", "寒冷");

    //1.将构造函数私有化  目的 ->防止直接 new
    //2. 去掉setXXX方法 防止属性被修改
    //3. 在Season内部直接创建固定的对象
    private Season(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return "Season{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}